<template>
  <div class="operate-class">
    <div>{{nodeData.i18nText}}</div>
    <el-checkbox-group v-model="checkList" style="margin-left: 16px" @change="checkChange">
      <el-checkbox v-for="(item, index) in nodeData.operateList" :key="index" :label="item.btnId" style="margin-left: 10px">{{item.btnName}}</el-checkbox>
    </el-checkbox-group>
  </div>
</template>

<script>
    export default {
      data(){
        return {
          checkList:[]
        };
      },
      created(){
        if (this.nodeData.operateList && this.nodeData.operateList.length > 0) {
          this.nodeData.operateList.forEach((item)=>{
            if (item.checked) {
              this.checkList.push(item.btnId)
            }
          });
        }
      },
      props:{
        nodeData:{
          type: Object
        },
        operateCheckList:{
          type: Array
        }
      },
      methods:{
        checkChange(data){
          this.$emit('check-change', {
            id: this.nodeData.id,
            operateListChecked: data
          });
        },
        checkAll(){
          if (this.nodeData.operateList && this.nodeData.operateList.length > 0) {
            this.checkList = [];
            this.nodeData.operateList.forEach((item)=>{
              this.checkList.push(item.btnId);
            });
            this.$emit('check-change', {
              id: this.nodeData.id,
              operateListChecked: this.checkList
            });
          }
        },
        cancelAll(){
          if (this.nodeData.operateList && this.nodeData.operateList.length > 0) {
            this.checkList = [];
            this.$emit('check-change', {
              id: this.nodeData.id,
              operateListChecked: this.checkList
            });
          }
        }
      }
    }
</script>

<style scoped>
  .operate-class{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }
</style>
